package com.sixth.docker.controller;

import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sixth.core.entity.Registration;
import com.sixth.core.vo.R;
import com.sixth.docker.service.CareHistoryService;
import com.sixth.docker.service.RegistrationService;
import com.sixth.docker.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Random;

/**
 * @program: sixth-hospital-parent
 * @description:
 * @author: 赵庆龙
 * @create: 2024-08-16 15:44
 **/
@RestController
@RequestMapping("/doctor/registration")
@Api(tags = "挂号流水")
public class RegistrationController {
    @Autowired
    private RegistrationService registrationService;
    @Autowired
    private CareHistoryService careHistoryService;
    @PostMapping("/insert")
    public R<Registration> insert(@RequestBody Registration registration) {

        return registrationService.insert(registration);
    }
    @PutMapping("/updateStatus")
    public R<Registration> updateStatus(@RequestBody Registration registration) {
        return registrationService.updateStatus(registration);
    }
    @PostMapping("/selectByPage")
    @ApiOperation(value = "分页查询挂号流水", notes = "获取挂号流水的分页统计数据")
    public R<IPage<Registration>> selectByPage(@RequestBody RegistrationVo registrationVo) {
        return registrationService.selectByPage(registrationVo);
    }
    @ApiOperation("查询待就诊列表")
    @PostMapping("/queryToBeSeen")
    public R<List<Registration>> queryToBeSeen(@RequestBody RegistrationStatusVo registrationStatusVo) {
        return registrationService.queryToBeSeen(registrationStatusVo);
    }
    @ApiOperation("查询就诊中列表")
    @PostMapping("/queryVisiting")
    public R<List<Registration>> queryVisiting(@RequestBody RegistrationStatusVo registrationStatusVo) {
        return registrationService.queryVisiting(registrationStatusVo);
    }
    @ApiOperation("查询已就诊列表")
    @PostMapping("/queryVisitCompleted")
    public R<List<Registration>> queryVisitCompleted(@RequestBody RegistrationStatusVo registrationStatusVo) {
        return registrationService.queryVisitCompleted(registrationStatusVo);
    }
    @PutMapping("/updateByStatus/{registrationId}/patient/{patientId}")
    public R<Registration> updateByStatus(@PathVariable String registrationId, @PathVariable String patientId) {
        // 使用 registrationId 和 patientId 处理业务逻辑
        careHistoryService.insertOrUpdate(  registrationId, patientId);  // 假设此处需要用到 patientId
        return registrationService.updateByStatus(registrationId);
    }

    @PostMapping("/getRegistrationListByStatus")
    public R<IPage<Registration>> selectByPageApp(@RequestBody RegistrationListStatusAppVo registrationListStatusAppVo) {
        return registrationService.selectByPageApp(registrationListStatusAppVo);
    }

    @PostMapping("/addAppRegistration")
    public R<Registration> addAppRegistration(@RequestBody RegistrationAppVo registrationAppVo) {
        return registrationService.addAppRegistration(registrationAppVo);
    }

    //根据挂号流水id进行删除
    @DeleteMapping("/deleteRegistration/{registrationId}")
    public R<Registration> deleteRegistration(@PathVariable String registrationId) {
        return registrationService.deleteRegistration(registrationId);
    }

    @PostMapping("/getAppointmentsBypatientId")
    public R<List<Registration>> getAppointmentsBypatientId(@RequestBody RegistrationStatusVo registrationStatusVo) {
        return registrationService.getAppointmentsBypatientId(registrationStatusVo);
    }

    @PostMapping("/selectReservations")
    public R<List<Registration>> selectReservations(@RequestBody ReservationsVo reservationsVo) {
        return registrationService.selectReservations(reservationsVo);
    }

    @PutMapping("/updateByReservation")
    public R<Registration> updateByReservation(@RequestBody Registration registration) {
        return registrationService.updateByReservation(registration);
    }
}
